<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Static Classes</title>
<meta name="generator" content="DocBook XSL Stylesheets V1.75.2">
<link rel="home" href="index.html" title="Smarty 3 Manual">
<link rel="up" href="advanced.features.html" title="Chapter 17. Advanced Features">
<link rel="prev" href="advanced.features.objects.html" title="Objects">
<link rel="next" href="advanced.features.prefilters.html" title="Prefilters">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<div class="navheader">
<table width="100%" summary="Navigation header">
<tr><th colspan="3" align="center">Static Classes</th></tr>
<tr>
<td width="20%" align="left">
<a accesskey="p" href="advanced.features.objects.html">Prev</a> </td>
<th width="60%" align="center">Chapter 17. Advanced Features</th>
<td width="20%" align="right"> <a accesskey="n" href="advanced.features.prefilters.html">Next</a>
</td>
</tr>
</table>
<hr>
</div>
<div class="sect1" title="Static Classes">
<div class="titlepage"><div><div><h2 class="title" style="clear: both">
<a name="advanced.features.static.classes"></a>Static Classes</h2></div></div></div>
<p>
  You can directly access static classes. The syntax is the same as in PHP.
 </p>
<div class="note" title="Note" style="margin-left: 0.5in; margin-right: 0.5in;">
<h3 class="title">Note</h3>
<p>
   Direct access to PHP classes is not recommended. This ties the underlying application code structure directly to the presentation, and also complicates template syntax. It is recommended to register plugins which insulate templates from PHP classes/objects. Use at your own discretion. See the Best Practices section of the Smarty website.
 </p>
</div>
<div class="example">
<a name="id459785"></a><p class="title"><b>Example 17.10. static class access syntax </b></p>
<div class="example-contents"><pre class="programlisting">

{assign var=foo value=myclass::BAR}  &lt;--- class constant BAR

{assign var=foo value=myclass::method()}  &lt;--- method result

{assign var=foo value=myclass::method1()-&gt;method2}  &lt;--- method chaining

{assign var=foo value=myclass::$bar}  &lt;--- property bar of class myclass

{assign var=foo value=$bar::method}  &lt;--- using Smarty variable bar as class name


  </pre></div>
</div>
<br class="example-break">
</div>
<div class="navfooter">
<hr>
<table width="100%" summary="Navigation footer">
<tr>
<td width="40%" align="left">
<a accesskey="p" href="advanced.features.objects.html">Prev</a> </td>
<td width="20%" align="center"><a accesskey="u" href="advanced.features.html">Up</a></td>
<td width="40%" align="right"> <a accesskey="n" href="advanced.features.prefilters.html">Next</a>
</td>
</tr>
<tr>
<td width="40%" align="left" valign="top">Objects </td>
<td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td>
<td width="40%" align="right" valign="top"> Prefilters</td>
</tr>
</table>
</div>
</body>
</html>
